forum

Home / DeveloperSection / Forums / Setting ContentType = “image/tiff” and sending an image is not working in IE

Setting ContentType = “image/tiff” and sending an image is not working in IE

Mark Devid257026-Aug-2014

I need to send an image (as a downloadable file) from an ASP web page. It is working correctly in every browser except for IE (all versions).

Here is the server side code:

bool export = Request.QueryString["Export"] != null;

if (export)

{

    byte[] allBytes = File.ReadAllBytes(@"C:\MyImage.tif");

    Response.ContentType = "image/tiff";

    Response.AddHeader("content-disposition", "attachment; filename=\"MyImage.tif\"");

    Response.OutputStream.Write(allBytes, 0, allBytes.Length);

    Response.OutputStream.Flush();

    Response.End();

    return;

}

And here is the JavaScript:

$('#ExportFrame').attr('src', 'Default.aspx?Export=true'); // ExportFrame is an iframe

In IE, I keep getting an error saying "Internet Explorer cannot download Default.aspx from localhost". I thought it might be an issue with loading it in an iframe element, but redirecting to the URL is not working either. The really odd thing is that going to the URL (/Default.aspx?Export=true) does not work the first time, but works every time after that. Again, this works in every browser I've tried except IE.

Any ideas?


Updated on 26-Aug-2014

Can you answer this question?


Answer

1 Answers

Liked By